package cn.stronglink.asset.module.dam.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import cn.stronglink.asset.module.dam.entity.dev.RackInfo;
import cn.stronglink.asset.module.dam.entity.message.MsgScreenCommand;
import cn.stronglink.asset.module.dam.entity.message.basicMsg.DamMqMessage;
import cn.stronglink.asset.module.dam.entity.message.secondMsg.AwsPostdataCommand;
import cn.stronglink.asset.module.dam.interfaces.CommandStrategyI;
import cn.stronglink.asset.module.dam.mapper.DamSensorMapper;
import cn.stronglink.asset.module.dam.utils.factorys.req.Factory2RackInfo;

@Service("getRackInfoService")
public class ScreenReqGetRackInfoService implements CommandStrategyI {
	@Autowired
	private DamSensorMapper damSensorMapper;

	@Override
	public void handleDamDatas(DamMqMessage msg) {
		MsgScreenCommand msgScreenCommand = (MsgScreenCommand) msg;
		AwsPostdataCommand datas = msgScreenCommand.getAwsPostdata();
		String rackConverCode = datas.getRackConverCode();

		RackInfo info = damSensorMapper.getRackInfo(rackConverCode);
		info.setRackConverCode(rackConverCode);
		System.out.println("机柜信息==========》");
		System.out.println(info.getIp());
		System.out.println(info.getRackConverCode());
		System.out.println(info.getAssetCount());
		System.out.println(info.getUsedU());
		System.out.println(info.getRackId());
		System.out.println(info.getTotalU());
		System.out.println("机柜信息==========》end");
		Factory2RackInfo.open2RackInfo(msgScreenCommand, info);
	}

	@Override
	public boolean isHandle(int screenId) {
		// 2: 机柜信息
		if (screenId == 2)
			return true;
		return false;
	}

}